<%--
  Created by IntelliJ IDEA.
  User: 王旭东
  Date: 2024/12/21
  Time: 22:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>宠物评论</title>
    <!-- 引入Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <!-- 引入Font Awesome 图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .pet-card {
            transition: transform 0.2s;
        }
        .pet-card:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        .comment-table th, .comment-table td {
            vertical-align: middle;
        }
        .comment-table th {
            background-color: #343a40;
            color: #fff;
        }
        .add-comment-form {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .add-comment-form textarea {
            resize: none;
        }
        .pet-image {
            height: 200px;
            object-fit: cover;
        }
        .pet-info {
            background-color: #f1f1f1;
        }
        .scrollable-container {
            max-height: 400px; /* 设置最大高度，根据需要调整 */
            overflow-y: auto;
        }
        .scrollable-container table {
            margin-bottom: 0;
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<jsp:include page="navigation.jsp"></jsp:include>

<div class="container my-5">
    <!-- 宠物展示 -->
    <div class="row mb-4" id="petListContainer">
        <div class="col-12">
            <h2 class="mb-4">宠物展示</h2>
            <div class="scrollable-container">
                <div class="row">
                    <c:forEach items="${petList}" var="pet">
                        <div class="col-md-4">
                            <div class="card pet-card mb-4">
                                <img src="${pageContext.request.contextPath}/static/images/animal/${pet.pic}" class="card-img-top pet-image" alt="宠物图片">
                                <div class="card-body pet-info">
                                    <h5 class="card-title">${pet.petName}</h5>
                                </div>
                            </div>
                        </div>
                    </c:forEach>
                </div>
            </div>
        </div>
    </div>

    <!-- 评论列表 -->
    <div class="row">
        <div class="col-12">
            <h2 class="mb-4">评论列表</h2>
            <div class="scrollable-container">
                <table class="table table-bordered table-striped comment-table" id="comment_table">
                    <thead>
                    <tr>
                        <th>评论人</th>
                        <th>宠物</th>
                        <th>评论内容</th>
                        <th>评论时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${commentList}" var="comment">
                        <tr>
                            <td>${comment.user.userName}</td>
                            <td>${comment.pet.petName}</td>
                            <td>${comment.content}</td>
                            <td>${comment.commentTime}</td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- 操作按钮 -->
    <div class="mt-5 d-flex flex-column flex-md-row justify-content-md-start">
        <a href="${pageContext.request.contextPath}/user/AdoptAdd" >
            <i class="fas fa-paw mr-2"></i> 我要领养
        </a>&nbsp; &nbsp;&nbsp;&nbsp;
        <a href="${pageContext.request.contextPath}/user/commentAdd" >
            <i class="fas fa-comment mr-2"></i> 我要评论
        </a>

    </div>

</div>
<a href="${pageContext.request.contextPath}/Linux/linux.jsp"></a>
<!-- 引入jQuery 和 Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>